import { get } from './base'
import { SongProp } from '@/store/type'
import { SongProps } from '@/views/song/index.vue'

export const getSingerList = (params?: any) => {
    return get('/api/getSingerList', { params })
}

export const getSingerDetail = (singer: SongProp) => {
    return get('/api/getSingerDetail', { params: { mid: singer.mid } })
}

export const getSongsUrl = async (songs: SongProps[]) => {
    if (!songs.length) {
        return Promise.resolve([])
    }
    const mids = songs.map(song => song.mid)
    const { map } = await get('/api/getSongsUrl', { params: { mid: mids } })
    return songs.map(song => {
        song.url = map[song.mid]
        return song
    }).filter(song => song.url.includes('vkey'))
}
